package com.mtgdeckbuilder.server.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.apache.commons.lang.StringUtils;

import com.google.appengine.api.datastore.Key;

/**
 * The object that represents a deck.
 * 
 * @author Nicolas Deslandes
 */
@SuppressWarnings("serial")
@Entity
public class Deck implements Serializable {

   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Key key;

   private String name;

   private List<Key> cards;

   private String color;

   /**
    * The empty constructor. Initialisation of the arrays.
    */
   public Deck() {
      cards = new ArrayList<Key>();
   }

   /**
    * @return the key.
    */
   public Key getKey() {
      return key;
   }

   /**
    * @return the name.
    */
   public String getName() {
      return name;
   }

   /**
    * @param name the name to set.
    */
   public void setName(final String name) {
      this.name = name;
   }

   /**
    * @param nameInUpperCase the nameInUpperCase to set.
    * @deprecated this setter is mandatory by the jpa/jdo framework must be not be used.
    */
   @Deprecated
   public void setNameInUpperCase(final String nameInUpperCase) {
   }

   /**
    * @return the nameInUpperCase.
    */
   @Basic
   public String getNameInUpperCase() {
      if (StringUtils.isEmpty(name)) {
         return null;
      }
      return name.toUpperCase();
   }

   /**
    * @return the cards.
    */
   public List<Key> getCards() {
      return cards;
   }

   /**
    * @param cards the cards to set.
    */
   public void setCards(final List<Key> cards) {
      this.cards = cards;
   }

   /**
    * @param color the color to set.
    */
   public void setColor(final String color) {
      this.color = color;
   }

   /**
    * @return the color.
    */
   public String getColor() {
      return color;
   }

}
